package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.TransportSmsTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * created by wangjunfu on 2021-02-24 15:59:56
 */
@Repository
public class TransportSmsTemplateDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(TransportSmsTemplateDao.class);

    public TransportSmsTemplate insert(final TransportSmsTemplate transportSmsTemplate) {
        insert("TransportSmsTemplate.insert", transportSmsTemplate);
        return transportSmsTemplate;
    }

    public Boolean updateInfoById(final TransportSmsTemplate transportSmsTemplate) {
        return update("TransportSmsTemplate.updateInfoById", transportSmsTemplate) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("TransportSmsTemplate.updateInfoByQuery", query) > 0;
    }

    public TransportSmsTemplate selectById(final Integer id, final Integer entId) {
        Query query = Query.noPage();
        query.put("id", id);
        query.put("entId", entId);
        return queryForObject("TransportSmsTemplate.selectById", query);
    }

    public List<TransportSmsTemplate> selectByQuery(final Query query) {
        return queryForList("TransportSmsTemplate.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("TransportSmsTemplate.countByQuery", query);
    }

    public Boolean deleteById(final Integer id, final Integer entId) {
        TransportSmsTemplate transportSmsTemplate = new TransportSmsTemplate();
        transportSmsTemplate.setDeleteFlag(1);
        transportSmsTemplate.setId(id);
        transportSmsTemplate.setEntId(entId);

        return update("TransportSmsTemplate.updateInfoById", transportSmsTemplate) > 0;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("TransportSmsTemplate.deleteById", query) > 0;
    }
}